<?php
/**
 *
 *
 *
 */
namespace Yz\modules\Users;

use Yz_String,
    Yz_SQL_Statement;
class Action_SelectByLogin
    extends \Yz_Action_Select
{

    /**
     *  @var string
     */
    protected $login;


    /************************************
     *         Public methods          *
     ************************************/

    /**
     *  set the login to search user by
     *
     *  @todo check login length
     *  @param string $login != ""
     *  @return chainable
     */
    public function setLogin( $login )
    {
        debug();
        $this->login = Yz_String::testNotEmpty($login);
        return $this;
    }



    /************************************
     *       Protected methods          *
     ************************************/


    /** Verify any arguments before building query
     *      ensure the login is set
     *  @return this
     */
    protected function verifyArguments()
    {
        debug();
        if (null === $this->login)
            throw \Yz_Action_Exception::_new("Missing required parameter 'login'");
        return $this;
    }


    /**
     *  Apply the arguments to the SQL statement
     *      Setup limit to avoid occasional selection of all rows
     *  @param Yz_SQL_Statement $sql
     *  @return this
     */
    protected function applyArguments(Yz_SQL_Statement $sql)
    {
        debug();
        $sql
            ->where("login=:_login")
            ->bind("_login", $this->login);
        ;
        return $this;
    }

}
